import {ServicePrefixEnum} from "@/enums/commonEnum";
import {RequestEnum} from "@/enums/httpEnum";
import type {AxiosRequestConfig} from "axios";
import {defHttp} from "@/utils/http/axios";

export interface NotifyMessageVO {
  id: number
  userId: number
  userType: number
  templateId: number
  templateCode: string
  templateNickname: string
  templateContent: string
  templateType: number
  templateParams: string
  readStatus: boolean
  readTime: Date
  createTime: Date
}
const MODULAR = '/system/notify-message';

export const Api = {
  GetNotifyMessagePage:{
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/page`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  GetMyNotifyMessagePage:{
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/my-page`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  UpdateNotifyMessageRead:{
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/update-read`,
    method: RequestEnum.PUT,
  } as AxiosRequestConfig,
  UpdateAllNotifyMessageRead:{
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/update-all-read`,
    method: RequestEnum.PUT,
  } as AxiosRequestConfig,
  GetUnreadNotifyMessageList:{
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/get-unread-list`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  GetUnreadNotifyMessageCount:{
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/get-unread-count`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig
}

// 查询站内信消息列表
export const getNotifyMessagePage = (params) => {
  return defHttp.request({ ...Api.GetNotifyMessagePage,params})
}

// 获得我的站内信分页
export const getMyNotifyMessagePage = (params) => {
  return defHttp.request({ ...Api.GetMyNotifyMessagePage,params})
}

// 批量标记已读
export const updateNotifyMessageRead = (ids) => {
  let params = {ids:ids,indices: false}
  return defHttp.request({ ...Api.UpdateNotifyMessageRead,params})
}

// 标记所有站内信为已读
export const updateAllNotifyMessageRead = () => {
  return defHttp.request({ ...Api.UpdateAllNotifyMessageRead})
}

// 获取当前用户的最新站内信列表
export const getUnreadNotifyMessageList = () => {
  return defHttp.request({ ...Api.GetUnreadNotifyMessageList})
}

// 获得当前用户的未读站内信数量
export const getUnreadNotifyMessageCount = () => {
  return defHttp.request({ ...Api.GetUnreadNotifyMessageCount})
}